package file;

import java.io.File;
import java.text.SimpleDateFormat;

/**
 * @author wang hao
 * @date 2023-03-30 19:39
 */
public class Demo01 {
    public static void main(String[] args) {

        File file = new File("src/main/java/file/1.txt");
        boolean file1 = file.isFile();
        System.out.println(file1);

        long length = file.length();
        System.out.println(length);

        // 也可以是 文件夹
        file = new File("src");

        System.out.println(file.isDirectory());

        System.out.println(file.getAbsolutePath());

        file = new File("src/main/java/file/1.txt");
        // 获取文件最后修改时间
        long l = file.lastModified();
        System.out.println(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(l));
    }
}
